home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10799 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  932 b 

  1. From: root@205.218.34.39 (where is my fish?)
  2. Subject: Re: a C++ beginner question
  3. Newsgroups: comp.lang.c++
  4. References: <4ggmem$5dc@leol.net-link.net>
  5. Reply-To: wjl@sisna.com
  6. X-Newsreader: TIN [version 1.2 PL2]
  7. NNTP-Posting-Host: dialup1339.sisna.com
  8. Message-ID: <313fd18c.0@news.sisna.com>
  9. Date: 8 Mar 96 06:19:56 GMT
  10. Path: 205.218.34.39!root
  11.  
  12. Jonathan S. Nachtigal (jnachtig@serv01.net-link.net) wrote:
  13. : Could someone please tell me how to do fractorial on C++.
  14. : Thank you :)
  15.  
  16. Unless there is a function for doing factorials directly, which I don't
  17. believe there is, I'd just use something like this, using really whatever
  18. types you want, if you don't like these:
  19.  
  20. unsigned long factorial(unsigned char c) { 
  21.     for (unsigned long f = c;c>1;--c) f *= c; 
  22.     return f;
  23. }
  24.  
  25. Nothing special about it being C++, unless you wanted a factorial class, which
  26. is pretty silly. :)
  27.  
  28. --
  29. where is my fish?
  30. wjl@sisna.com
  31. wjl@blarg.net
  32. wjl@byu.edu
  33.